package com.compass.doctor.ui.mine.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.callback.OnCustomButtonClick
import com.compass.doctor.databinding.LayoutBankCardItemBinding
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.ext.onClick
import com.compass.framework.model.BankCard

/**
 * Description： 银行卡adapter
 * Date:2023/12/26 21:11
 */
class BankCardAdapter : BaseRecyclerViewAdapter<BankCard, LayoutBankCardItemBinding>() {

    private lateinit var onCustomBottomClick:OnCustomButtonClick

    fun setBottomCallBack(onBottomClick: OnCustomButtonClick) {
        this.onCustomBottomClick = onBottomClick
    }
    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutBankCardItemBinding {
        return LayoutBankCardItemBinding.inflate(layoutInflater, parent, false)
    }

    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutBankCardItemBinding>,
        item: BankCard?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            bankName.text=item.bankName
            bankCardNumber.text=item.bankCardNumber
            tvUntie.onClick {
                onCustomBottomClick.onButtonCallBack(position,"untie")
            }
            tvCompleteCardNumber.onClick {
                onCustomBottomClick.onButtonCallBack(position,"cardNumber")
            }
        }
    }
}